<?php 
	$paramOrder = '&order='.$orderByCol;
	$descCol = $objDef->descriptor;
	$page = $pager->getPage();
	
?>
<div style="width: 100%; height: 1px;"></div>
<?php 
	if($totalRecords==0){
		$msgQ = __("No items");
		$nbpages = 0;
	}else{
		$start = (($page-1) * $nbPosts)+1;
		$end = $start + $nbPosts - 1;
		$nbpages = 1;	
		if($nbPosts != 0)
		{
			$nbpages = intval($totalRecords / $nbPosts);
			if(fmod($totalRecords,$nbPosts) != 0)
			{
				$nbpages++;
			}
		}
		if($end > $totalRecords) $end = $totalRecords;
		$msgQ = __("Displaying <b>%from%</b> to <b>%to%</b> of <b>%total%</b> item(s) on <b>%pages%</b> page(s)",
		array('%from%'=>$start, '%to%'=>$end, '%total%'=>$totalRecords, '%pages%'=>$nbpages ));
	}
?>
<div id="displayDescription"><?php echo $msgQ?></div>
<div id="pag_nav_haut">
<?php 
		if($nbpages > 1)
		{		
			$nbPagesControl .= __("Show page :");
			$nbPagesControl .= '<input id="nbPagesInput" type="text" value="'.$page.'" onChange="javascript: refresh(\''.$view.'\',this.value ,'.$nbPosts.',\''.$orderByCol.'\' );">';
			$nbPagesControl .= '<a href="javascript: refresh(\''.$view.'\',this.value ,'.$nbPosts.',\''.$orderByCol.'\'  );"><img align="absmiddle" src="/images/icons/16/navigation/valider16.png" title="'.__('Show').'"/></a>';
			
			echo '<div id="nbPagesControl">'.$nbPagesControl.'</div>';			
			
			echo __('Navigation :');
			echo ambnoyFuncs::pager_navigation($pager, $view, $orderByCol, $nbPosts);
			//$html .= $pager_navigation($totalRecords,$start,$nbPosts,$nbpage);
		}

?>
</div>
<table class="dossier_list">
<?php 
		$functionParams = '\''.$view.'\','.$pager->getPage().','. $nbPosts;
		echo $objDef->renderListHeader($hide,'table',true, 0, true,$functionParams, $orderByCol, $add);
		
		
?>
<tbody>
<?php 
    $i = 0;
	foreach($records as $item):?>
	<tr>
	<td id="actionscol">
	<a href="<?php echo url_for($moduleRef.'/show?id='.$item['id'].'&view='.$view.$paramOrder.'&page='.$page);?>">
	<img alt="" src="/images/icons/32/show.png">
	</a>
	</td>
	<?php 
			
			echo $objDef->renderListAttributes($item, $hide);
			if(count($objDef->attributesWithTotal)>0){
				foreach ($objDef->attributesWithTotal as $fieldname => $config){
					$objDef->attributesWithTotal[$fieldname]['value'] = $objDef->attributesWithTotal[$fieldname]['value'] + $item[$fieldname]; 
				}
			}
			$i++;
		?>
		</tr>
<?php endforeach;?>	
<?php
		
		if(count($objDef->attributesWithTotal)>0){
			echo $objDef->renderListFooter($hide,'table',$addActions, 0);
		}
		
		echo '<input type="hidden" id="q_list_'. $objDef->className.'" value="' . $i . '">';
		
?>
</tbody>
</table>
<?php

		$nbPostsControl = '<span>'.__("Showing").' <input id="nbPostsInput" type="text" value="'.$nbPosts.'" onChange="javascript: refresh(\''.$view.'\',1, this.value,\''.$orderByCol.'\' );"> '.__("items per page");
		$nbPostsControl .= '<a href="javascript: refresh(\''.$view.'\',1, this.value,\''.$orderByCol.'\' );"><img align="absmiddle" src="/images/icons/16/refresh.png" title="'.__('Refresh').'"/></a>';
		echo '<div id="nbPostsControl">'.$nbPostsControl.'</div>';
		if($nbpages > 1)
		{
			echo '<div id="pag_nav_bas">';
			
			echo '<div id="nbPagesControl">'.$nbPagesControl.'</div>';			
			
			echo __('Navigation :');
			echo ambnoyFuncs::pager_navigation($pager, $view, $tab, $orderByCol, $nbPosts);
			echo '</div>';
		}